import request from '@/utils/request'
//登陆
export function login(data) {
  return request({
    url: '/authentication',
    method: 'post',
    auth:data
  })
}
//权限管理
export function permissionslist(data) {
  return request({
    url: '/permissions',
    method: 'get',
    data
  })
}
export function permissionspost(data) {
  return request({
    url: '/permissions',
    method: 'post',
    data
  })
}
export function permissionsput(id,data) {
  return request({
    url: `/permissions/${id}`,
    headers: {
      'Content-Type': 'application/json'
    },
    method: 'put',
    data
  })
}
export function permissionsdel(id) {
  return request({
    url: `/permissions/${id}`,
    method: 'delete'
  })
}
//角色管理
export function roles(data) {
  return request({
    url: '/roles',
    method: 'get',
    data
  })
}
export function rolespost(data) {
  return request({
    url: '/roles',
    method: 'post',
    data
  })
}
export function rolesput(id,data) {
  return request({
    url: `/roles/${id}`,
    method: 'put',
    data
  })
}
export function rolesdel(id) {
  return request({
    url: `/roles/${id}`,
    method: 'delete'
  })
}
//用户管理
export function users(data) {
  return request({
    url: '/users',
    method: 'get',
    data
  })
}
export function userspost(data) {
  return request({
    url: '/users',
    method: 'post',
    data
  })
}
export function usersput(id,data) {
  return request({
    url: `/users/${id}`,
    method: 'put',
    data
  })
}
export function usersdel(id) {
  return request({
    url: `/users/${id}`,
    method: 'delete',
  })
}
export function usersputpassword(id,data) {
  return request({
    url: `/users/${id}/password`,
    method: 'put',
    data
  })
}
export function usersinfo(data) {
  return request({
    url: '/users/me',
    method: 'get',
    data
  })
}
//部门管理

export function departmentspost(data) {
  return request({
    url: '/departments',
    method: 'post',
    data
  })
}
export function getdepartments(data) {
  return request({
    url: `/departments/${id}`,
    method: 'get',
    data
  })
}
export function departmentsput(id,data) {
  return request({
    url: `/departments/${id}`,
    method: 'put',
    data
  })
}
export function departmentsdel(id) {
  return request({
    url: `/departments/${id}`,
    method: 'delete'
  })
}

export function departmentstree(data) {
  return request({
    url: '/departments/tree',
    method: 'get',
    data
  })
}
export function departmentstreewithuser(data) {
  return request({
    url: '/departments/tree/with-users',
    method: 'get',
    data
  })
}
//租户管理

export function tenants(data) {
  return request({
    url: '/tenants',
    method: 'get',
    data
  })
}
export function tenantspost(data) {
  return request({
    url: '/tenants',
    method: 'post',
    data
  })
}
export function tenantsput(id,data) {
  return request({
    url: `/tenants/${id}`,
    method: 'put',
    data
  })
}
export function tenantsdel(id) {
  return request({
    url: `/tenants/${id}`,
    method: 'delete'
  })
}

export function tenantsswitch(id,data) {
  return request({
    url: `/tenants/${id}/switch`,
    method: 'post',
    data
  })
}
export function tenantsavailable(data) {
  return request({
    url: '/tenants/available',
    method: 'get',
    data
  })
}
//表单管理
export function forms(data) {
  return request({
    url: '/forms',
    method: 'get',
    data
  })
}
export function formspost(data) {
  return request({
    url: '/forms',
    method: 'post',
    data
  })
}
export function formsput(id,data) {
  return request({
    url: `/forms/${id}`,
    method: 'put',
    data
  })
}
export function formsdel(id) {
  return request({
    url: `/forms/${id}`,
    method: 'delete'
  })
}
//表单项管理
export function formsitems(id,data) {
  return request({
    url: `/forms/${id}/items`,
    method: 'get',
    data
  })
}
export function formsitemspost(data) {
  return request({
    url: `/forms/${id}/items`,
    method: 'post',
    data
  })
}
export function formsitemsput(formId,id,data) {
  return request({
    url: `/forms/${formId}/items/${id}`,
    method: 'put',
    data
  })
}
export function formsitemsdel(formId,id) {
  return request({
    url: `/forms/${formId}/items/${id}`,
    method: 'delete'
  })
}
export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}
